package org.erp.product.infrastructure.config;

import org.erp.common.constant.RabbitmqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author libin
 * @version 1.0
 * @description:
 * @date 2025/11/19 23:15
 **/
@Configuration
public class RabbitmqConfig {

    @Bean
    public DirectExchange createExchange() {
        return new DirectExchange(RabbitmqConstant.ERP_PRODUCT_EXCHANGE);
    }

    @Bean
    public Queue createQueue() {
        return new Queue(RabbitmqConstant.ERP_PRODUCT_QUEUE);
    }

    @Bean
    public Binding createBinding(DirectExchange directExchange, Queue queue) {
        return BindingBuilder.bind(queue).to(directExchange).with(RabbitmqConstant.ERP_PRODUCT_ROUTING_KEY);
    }


}
